Common Functions
Enter the support/common-functions/
folder and go through the practice items below.
If you get stuck, take a sneak peek at the solutions in the solution/common-functions/
folder.
Update the
putchar()
function inmain_printf.c
to implement a buffered functionality ofprintf()
. Characters passed via theputchar()
call will be stored in a predefined static global buffer. Thewrite()
call will be invoked when a newline is encountered or when the buffer is full. This results in a reduced number ofwrite
system calls. Usestrace
to confirm the reduction of the number ofwrite
system calls.Update the
main_printf.c
file to also feature aflush()
function that forces the flushing of the static global buffer and awrite
system call. Make calls toprintf()
andflush()
to validate the implementation. Usestrace
to inspect thewrite
system calls invoked byprintf()
andflush()
.